var intNowBT = 11;
var arrSNum = [1, 2, 3, 4];

function CheckChoice(){
	var arrChBox = new Array(), j = 0, i = 0, objChBox, intBT = 11;
	var intMaxSd = 20, isFull = 0, intTotal = 0, intSNum;
	with(document.ShowOddsForm){
		for(j = 0; j < arrSNum.length; j++){
			intSNum = arrSNum[j];
			arrChBox[intSNum] = 0;
			for(i = 0; i <= 9; i++){
				objChBox = document.ShowOddsForm["CNumber["+intSNum.toString()+"]["+i.toString()+"]"];
				objChBox.disabled = false;
				ChangeClass(i, intSNum, 0);
				if(objChBox.checked){
					arrChBox[intSNum]++;
					intTotal++;
					ChangeClass(i, intSNum, 1);
				}
				if(intTotal == intMaxSd){
					break;
				}
			}
		}

		if(intTotal == intMaxSd){
			for(j = 0; j < arrSNum.length; j++){
				intSNum = arrSNum[j];
				for(i = 0; i <= 9; i++){
					objChBox = document.ShowOddsForm["CNumber["+intSNum.toString()+"]["+i+"]"];
					if(objChBox.checked == false)objChBox.disabled = true;
				}
			}
		}
		BSubmit.disabled = true;
		if(intTotal >= arrSNum.length){
			BSubmit.disabled = false;
			for(j = 0; j < arrChBox.length; j++){
				if(arrChBox[j] == 0){
					BSubmit.disabled = true;
					break;
				}
			}
		}
		return (intTotal == intMaxSd)?false:true;
	}
}


function ChangeBT(intBT){
	var i = 0;
	for(i = 1; i <= 13; i++){
		document.getElementById("NSBar"+i.toString()).className = "rt_sp_nsbar";
	}
	document.getElementById("NSBar"+intBT.toString()).className = "rt_sp_nsbar_sd";
	
	for(i = 1; i <= 4; i++){
		document.getElementById("SelectN"+i.toString()).style.display = "block";
	}

	arrSNum = [1, 2, 3, 4];
	switch(intBT){
		case 1:
			arrSNum = [3, 4];
			document.getElementById("SelectN2").style.display = "none";
			document.getElementById("SelectN1").style.display = "none";
			break;

		case 2:
			arrSNum = [2, 4];
			document.getElementById("SelectN3").style.display = "none";
			document.getElementById("SelectN1").style.display = "none";
			break;

		case 3:
			arrSNum = [1, 4];
			document.getElementById("SelectN3").style.display = "none";
			document.getElementById("SelectN2").style.display = "none";
			break;

		case 4:
			arrSNum = [2, 3];
			document.getElementById("SelectN4").style.display = "none";
			document.getElementById("SelectN1").style.display = "none";
			break;

		case 5:
			arrSNum = [1, 3];
			document.getElementById("SelectN4").style.display = "none";
			document.getElementById("SelectN2").style.display = "none";
			break;

		case 6:
		case 12:
			arrSNum = [1, 2];
			document.getElementById("SelectN4").style.display = "none";
			document.getElementById("SelectN3").style.display = "none";
			break;

		case 7:
			arrSNum = [2, 3, 4];
			document.getElementById("SelectN1").style.display = "none";
			break;

		case 8:
			arrSNum = [1, 3, 4];
			document.getElementById("SelectN2").style.display = "none";
			break;

		case 9:
			arrSNum = [1, 2, 4];
			document.getElementById("SelectN3").style.display = "none";
			break;

		case 10:
		case 13:
			arrSNum = [1, 2, 3];
			document.getElementById("SelectN4").style.display = "none";
			break;
	}
	intNowBT = intBT;
	ClearSelect();
}

function ClearSelect(){
	var i = 0, j = 0, intSNum = 0, objChBox;

	with(document.ShowOddsForm){
		for(j = 0; j < arrSNum.length; j++){
			intSNum = arrSNum[j];
			for(i = 0; i <= 9; i++){
				objChBox = document.ShowOddsForm["CNumber["+intSNum.toString()+"]["+i.toString()+"]"];
				objChBox.disabled = false;
				objChBox.checked = false;
				ChangeClass(i, intSNum, 0);
			}
		}
	}
}

function ChangeClass(intNum, intType, isOver){
	if(isOver == 1){
		document.getElementById("NumOdds"+intType.toString()+intNum.toString()).style.backgroundColor = '#CCFFCC';
	}else{
		if(document.ShowOddsForm["CNumber["+intType+"]["+intNum+"]"].checked == false)document.getElementById("NumOdds"+intType.toString()+intNum.toString()).style.backgroundColor = '#FFFFFF';
	}
}


function AddChoiceNumber(){
	var i = 0, j = 0, intSNum = 0, objChBox, k = 0;
	for(i = document.SendOddsForm.elements.length - 1; i >= 0; i--){
		var oChild = document.SendOddsForm.elements[i];
		if(oChild.name.indexOf("ChoiceNumber") >=0 ){
			document.SendOddsForm.removeChild(oChild);
		}
	}

	with(document.ShowOddsForm){
		for(j = 0; j < arrSNum.length; j++){
			intSNum = arrSNum[j];
			for(i = 0; i <= 9; i++){
				objChBox = document.ShowOddsForm["CNumber["+intSNum.toString()+"]["+i.toString()+"]"];
				if(objChBox.checked){
					k = j + 1;
					var objHidden = document.createElement("<input type='hidden' name='ChoiceNumber["+k.toString()+"]["+i.toString()+"]' value='"+i.toString()+"'>");

					document.SendOddsForm.elements[document.SendOddsForm.elements.length - 1].insertAdjacentElement("afterEnd", objHidden);
				}
			}
		}
	}
	document.SendOddsForm.Bet_Type.value = intNowBT;
	document.SendOddsForm.submit();
}

function SelectAllNum(isChecked, intSN){
	var i;
	for(i = 0; i <= 9; i++){
		document.ShowOddsForm["CNumber["+intSN.toString()+"]["+i.toString()+"]"].checked = isChecked;
		if(!CheckChoice())break;
	}
}